home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 401-425 / disk_408 / post / post13.lzh / Post / init.ps next >
Text File  |  1990-10-27  |  5KB  |  164 lines

  1. %! Post V1.3 initialisation file
  2. % (C) Adrian Aylward 1989, 1990
  3. %
  4. % You may freely copy, use, and modify this file
  5. %
  6. % This file should be run before most programs
  7.  
  8. % Ignore CTRL/D
  9.  
  10. <04> cvn {} def
  11.  
  12. % A dummy status dictionary
  13.  
  14. /statusdict 10 dict dup begin
  15. /waittimeout 0 def
  16. /checkpassword { 0 eq } bind def
  17. /product (Post V1.3) def
  18. end def
  19.  
  20. % A dummy server dictionary
  21.  
  22. /serverdict 5 dict dup begin
  23. /exitserver { pop } bind def
  24. end def
  25.  
  26. % A scratch string
  27.  
  28. /=string 256 string def
  29.  
  30. % Run a program with save and restore
  31.  
  32. /runsave
  33. { /saveobject save def
  34.   run
  35.   saveobject restore
  36. } bind def
  37.  
  38. % Run a program displaying its name
  39.  
  40. /runprog
  41. { dup print (\n) print
  42.   runsave
  43. } bind def
  44.  
  45. % New cache parameters ops
  46.  
  47. systemdict
  48. /setcacheparams
  49. { counttomark 1 ge { dup setcachelimit } if
  50.   cleartomark
  51. } bind put
  52.  
  53. systemdict
  54. /currentcacheparams
  55. { mark cachestatus 6 { exch pop} repeat dup
  56. } bind put
  57.  
  58. % Load a font file.  Build the file name string from the font name, prefix
  59. % and suffix strings.  We pop the dictionary stack first, so that the
  60. % contents of any additional entries on it can't interfere with the font
  61. % definition - e.g. if it uses the bind operator.  Then we try to open the
  62. % file.  If it opens OK we execute it; if the open fails we return without
  63. % error: presumabaly we don't have the font.  Before returning we restore the
  64. % dictionary stack.
  65.  
  66. systemdict
  67. /loadfont
  68. { 1 index =string copy                         % Prefix:
  69.   length                                       % length
  70.   3 index =string 2 index 100 getinterval cvs  % Prefix:name
  71.   length add                                   % length
  72.   1 index =string 2 index 100 getinterval copy % Prefix:name.suffix
  73.   length add                                   % length
  74.   =string exch 0 exch getinterval              % Truncate to length
  75.   mark countdictstack 2 sub
  76.       { currentdict end } repeat               % Pop dict stack
  77.   counttomark 1 add index                      % Get the file name
  78.   { fontfile } stopped                         % Try to open the file
  79.   { pop }                                      % Can't open it, ignore
  80.   { cvx exec }                                 % Opened OK, execute it
  81.   ifelse
  82.   counttomark { begin } repeat pop             % Restore dictionary stack
  83.   pop pop pop pop                              % Pop file name and arguments
  84. } bind put
  85.  
  86. % Find a font.  If it is not there we try in order:
  87. %
  88. %    Load       PSFonts:name
  89. %    Load       CGFonts:PS/name.psfont
  90. %    Load       PSFonts:OtherFonts/name
  91. %    Substitute DefaultFont
  92. %
  93. % If none of these succeeds, the result will an invalidfont error.
  94.  
  95. systemdict /.findfont systemdict /findfont get def
  96.  
  97. systemdict
  98. /findfont
  99. {
  100. % Comment out the next 3 lines if you don't have a PSFonts: directory
  101.   dup FontDirectory exch known not             % Not in FontDirectory?
  102.   { dup (PSFonts:) () loadfont                 % Try to load from PSFonts:
  103.   } if
  104. % Comment out the next 3 lines if you don't have the Gold Disk CG fonts
  105. % dup FontDirectory exch known not             % Not in FontDirectory?
  106. % { dup (CGFonts:PS/) (.psfont) loadfont       % Try CGFonts:PS
  107. % } if
  108. % Comment out the next 3 lines if you don't have a PSFonts:OtherFonts
  109.   dup FontDirectory exch known not             % Not in FontDirectory?
  110.   { dup (PSFonts:OtherFonts/) () loadfont      % Try PSFonts:OtherFonts
  111.   } if
  112. % Substitute DefaultFont
  113.   dup FontDirectory exch known not             % Not in FontDirectory?
  114.   { dup userdict /DefaultFontName get ne       % Not the DefaultFont
  115.     { pop userdict /DefaultFontName get        % Substitue DefaultFont
  116.       dup systemdict /findfont get exec pop    % Recurse so it gets loaded
  117.     }
  118.     if
  119.   }
  120.   if
  121.   dup FontDirectory exch known not             % Not in FontDirectory?
  122.   { pop /DummyFont } if                        % Fall back on DummyFont
  123.   .findfont                                    % If errors, will fail now
  124. } bind put
  125.  
  126. % Select a font
  127.  
  128. systemdict
  129. /selectfont
  130. { exch findfont exch
  131.   dup type /arraytype eq
  132.   { makefont }
  133.   { scalefont }
  134.   ifelse
  135.   setfont
  136. } bind put
  137.  
  138. % Define a dummy font - prints out big dots ...
  139.  
  140. /DummyFont 10 dict dup begin
  141. /FontName /DummyFont def
  142. /FontMatrix [0.001 0 0 0.001 0 0] def
  143. /FontType 3 def
  144. /FontBBox [0 -300 500 700] def
  145. /Encoding StandardEncoding def
  146. /BuildChar
  147. { pop pop
  148.   500 0 50 0 450 400 setcachedevice
  149.   250 200 200 0 360 arc fill
  150. } bind def
  151. /Painttype 0 def
  152. end definefont pop
  153.  
  154. % Establish the dummy font as the default, as some fonts need it to
  155. % define themselves.
  156.  
  157. /DefaultFontName /DummyFont def
  158.  
  159. % If you don't have Courier, comment this line out, or replace it with any
  160. % font you prefer.
  161.  
  162. %/DefaultFontName /Courier def
  163.  
  164.